package com.kichina.galaxy.dev.tools.aliyun.product;

import com.aliyun.iot20180120.Client;
import com.aliyun.tea.*;
import com.aliyun.iot20180120.models.*;
import com.aliyun.teaopenapi.models.*;
import com.aliyun.teautil.*;
import com.aliyun.teautil.models.*;
import com.kichina.galaxy.dev.tools.aliyun.AliyunConstant;


/**
 * @author Surging
 * @version 1.0
 * @ClassName ProductSampleTest
 * @date 2022-06-27 10:25
 * @desc 阿里云物联网平台产品添加测试
 */
public class ProductSampleTest {

    /**
     * 使用AK&SK初始化账号Client
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config()
                // 您的 AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的 AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = "iot.cn-beijing.aliyuncs.com";
        return new Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        Client client = ProductSample.createClient(AliyunConstant.ACCESS_KEY_ID, AliyunConstant.ACCESS_KEY_SECRET);
        CreateProductRequest createProductRequest = new CreateProductRequest();
        RuntimeOptions runtime = new RuntimeOptions();
        CreateProductResponse resp = client.createProductWithOptions(createProductRequest, runtime);
        com.aliyun.teaconsole.Client.log(Common.toJSONString(TeaModel.buildMap(resp)));
    }
}
